#ifndef DLL_LINKED_LIST_H
#define DLL_LINKED_LIST_H

#include "bbAddon.h"

using namespace std;

static int _Debug_COUNTLINKS	= 0;

/* Double Linked-List */
class TLink;
		
class TList{
public :
	TList();
	~TList();
	TLink* _head;
	TLink* _tail;
};

class TLink{
public :
	TLink();
	~TLink();
	TList* _list;
	string _data;
	TLink* _next;
	TLink* _prev;

	friend TLink* NullLink();
};

static TLink* _NULL_LINK = new TLink();

inline void Unlink(TLink* lnk);

BBAEXPvoid DeleteList (TList * list);
BBAEXPvoid DeleteLink (TLink * lnk);
BBAEXPvoid SetLinkValue (TLink* lnk, const char* datas);
BBAEXPint NewList();
BBAEXPint ListInsertAfter(TLink* lnk, TLink* after);
BBAEXPint ListInsertBefore(TLink* lnk, TLink* before);
BBAEXPint ListAddLast(TList* list, const char* pValue);
BBAEXPint ListAddFirst(TList* list, const char* pValue);
BBAEXPint ListContains(TList* list, const char* value);
BBAEXPcint ListIsEmpty(const TList* list);
BBAEXPcint FirstLink(const TList* list);
BBAEXPcint LastLink(const TList* list);
BBAEXPcint AfterLink(const TLink* link);
BBAEXPcint BeforeLink(const TLink* link);
BBAEXPint len(const char* a);
BBAEXPint LinkCompare(const TLink* l1, const TLink* l2);
BBAEXPint StrCompare(const char* a, const char* b);
BBAEXPstr LinkValue(const TLink* link);
BBAEXPint SwapLinks(TLink* l1, TLink* l2);
BBAEXPint SortList(TList* list, int sens);


#endif //DLL_LINKED_LIST_H